package com.shell.scheduler.executor.chainbill;

import com.shell.bee.base.utils.StringUtil;
import com.shell.bee.base.utils.SystemUtil;
import com.shell.bee.base.utils.SystemUtil.SystemMode;
import com.shell.feign.PubParameterFeign;
import com.shell.feign.UserPasswordUpateFeign;
import com.shell.governor.modules.vo.ParameterVo;
import com.shell.scheduler.Executor;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;

public class UserPasswordUpateBatchJobExecutor implements Executor {
	private static final long serialVersionUID = -6452094645965943764L;
	protected final Log logger = LogFactory.getLog(getClass());
	@Autowired
	private UserPasswordUpateFeign userPasswordUpateFeign;
	@Autowired
	private PubParameterFeign pubParameterFeign;
	private static final String SWITCH_ON = "on";
	private static final String SWITCH_OFF = "off";

	public void execute(Map<String, String> context) {
		this.logger.info(getClass().getName() + " is executing...");
		if (SystemUtil.SystemMode.test.equals(SystemUtil.getSystemMode())) {
			String autoUpdate = "off";
			ParameterVo parameter = this.pubParameterFeign.getCommonParameter("AUTO_UPDATE_USER_PASSWORD");
			if ((parameter != null) && (!StringUtil.emptyAndNull(parameter.getParmValue()))) {
				autoUpdate = parameter.getParmValue();
			}
			if ("on".equals(autoUpdate)) {
				this.userPasswordUpateFeign.updatePasswordExcludeAdmin();
			}
		}
		this.logger.debug(getClass().getName() + " is execut successful...");
	}
}